/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Model;

import Data.ChuyenTau;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

/**
 *
 * @author bienphongvnn
 */
public class ChuyenTauModel {
    public static ArrayList<ChuyenTau> ListChuyenTau() {	
        ArrayList<ChuyenTau> ds = new ArrayList<ChuyenTau>();	
        Connection con = ConnectionProvider.Connect();
	try {
            
            String sql = String.format("select distinct ct.MaChuyenTau from chuyentau ct, tuyentau tt where ct.MaTuyen = tt.MaTuyen");
            Statement statement	= con.createStatement();		
            ResultSet rs = statement.executeQuery(sql);	
            while(rs.next()){	
                ChuyenTau ct = new ChuyenTau();
                ct.MaChuyenTau = rs.getString("ct.MaChuyenTau");
                ds.add(ct);	
                } 
            con.close();
        }
        catch(Exception ex){
            System.out.println(ex.getMessage());	
        }
        finally
        {
           
        }
        return	ds;	
    }
}
